<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var minTimeToVisitAllPoints = function(points) {
    let count = 0
    for( var i = 0 ; i<points.length-1 ; i++ ){
        count += Math.max( Math.abs( points[i][0] - points[i+1][0] ) , Math.abs( points[i][1] - points[i+1][1] ) )
    }
    return count
};

// 45度斜着也是1，所以只要取x，y差值的最大值作为距离就行

var points = points = [[3,2],[-2,2]]
console.log(minTimeToVisitAllPoints(points))
    </script>
</body>
</html>